/*************************************************************************
* MediaCoder extension for Meizu miniPlayer
* Distributed under GPL license
* Copyright (c) 2006 Wu Xiaoyong <wuxy2000@citiz.net>
* All rights reserved.
*************************************************************************/

function ApplyParams()
{
	var doc = NewXML("MediaCoderPref");
	if (!doc) {
		alert("Error creating config XML");
		return;
	}
	
	var res = document.getElementById("res").value.split("x");
	var format = document.getElementById("format").value;
	
	switch (format) {
	case "MPEG1":
	case "MPEG2":
		AddPrefNode(doc, "overall.container.format", format);
		break;
	default:
		AddPrefNode(doc, "overall.container.format", "Default");
	}
	
	AddPrefNode(doc, "overall.video.format", format);
	AddPrefNode(doc, "overall.video.bitrate", document.getElementById("vb").value);
	AddPrefNode(doc, "audioenc.lame.quality", document.getElementById("aq").value);
	AddPrefNode(doc, "videofilter.frame.fps", document.getElementById("fps").value);
	AddPrefNode(doc, "videofilter.scale.width", res[0]);
	AddPrefNode(doc, "videofilter.scale.height", res[1]);
	
	// post settings to MediaCoder
	PostPrefXML(doc);
}

function Unload()
{
	// stop playback
	SendCommand("stop_play");
}
